Skip to content

[codex] validate required Codex agent descriptions#175

Merged
runkids merged 2 commits into
runkids:mainfrom
PeterTianbuhan:codex-agents-required-description
May 31, 2026
Merged

[codex] validate required Codex agent descriptions#175
runkids merged 2 commits into
runkids:mainfrom
PeterTianbuhan:codex-agents-required-description

Conversation

@PeterTianbuhan
Copy link
Copy Markdown
Contributor

Type

  • Bug fix
  • Small improvement (docs, typo, minor refactor)
  • Feature proposal (proposals/ only — see CONTRIBUTING.md)

Linked Issue

Related to #170

Summary

Codex TOML agents require a description field. The bundled codex-agents transform previously skipped empty frontmatter values, so a Markdown agent without description could sync successfully while producing TOML that Codex cannot load.

This change makes that failure explicit: extensions/codex-agents now rejects inputs without description frontmatter, exits non-zero with a clear message, and documents the requirement in both the extension README and extras docs.

Checklist

  • I've read CONTRIBUTING.md
  • Tests included and passing (make check) — for code changes
  • No unrelated changes in the diff
  • Scope is focused — one concern per PR

Validation

  • node -c extensions/codex-agents/convert.js
  • node -c extensions/codex-agents/md-toml.js
  • Verified the converter emits TOML with name, description, model, and developer_instructions when description is present.
  • Verified the converter exits non-zero with missing required frontmatter 'description' when description is absent.

I could not run make check locally because this Codex environment does not have go / gofmt installed.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces validation for the required description frontmatter field in the codex-agents extension, ensuring it exits with a non-zero status and a clear error message when missing. It also updates the documentation and adds Go tests to verify this behavior. The review feedback suggests improving the validation check by trimming whitespace to prevent whitespace-only descriptions from bypassing the check.

Comment thread extensions/codex-agents/convert.js Outdated
Comment on lines +5 to +9
if (!frontmatter.description) {
throw new Error(
"codex-agents: missing required frontmatter 'description' (Codex custom agents require description)"
);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

If the description frontmatter field contains only whitespace (e.g., description: " "), the current check !frontmatter.description will evaluate to false and bypass the validation. This would result in generating a TOML file with an empty/whitespace description, which Codex cannot load. Trimming the value before checking ensures that whitespace-only descriptions are also rejected.

Suggested change
if (!frontmatter.description) {
throw new Error(
"codex-agents: missing required frontmatter 'description' (Codex custom agents require description)"
);
}
if (!frontmatter.description || !frontmatter.description.trim()) {
throw new Error(
"codex-agents: missing required frontmatter 'description' (Codex custom agents require description)"
);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, good catch. Updated the check to reject whitespace-only descriptions and added a test case for it.

@PeterTianbuhan PeterTianbuhan marked this pull request as ready for review May 31, 2026 03:54
Copilot AI review requested due to automatic review settings May 31, 2026 03:54
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds validation in the bundled codex-agents extension to require a description frontmatter field, since Codex custom agents cannot load without it. Errors thrown from mapFields are now caught and surfaced via stderr with a non-zero exit code.

Changes:

  • Validate presence of non-empty description frontmatter in convert.js and throw a descriptive error.
  • Add error handling to md-toml.js convert() so thrown errors produce a clean stderr message and exit code 1.
  • Add Go tests exercising the bundled JavaScript extension via node, and update documentation.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
extensions/codex-agents/convert.js Adds required-field validation for description.
extensions/codex-agents/md-toml.js Catches promise rejections, writes message to stderr, exits 1.
internal/sync/extension_test.go Adds tests for successful conversion and missing/whitespace-only description.
extensions/README.md Documents the pattern of validating required fields in convert.js.
website/docs/reference/commands/extras.md Notes that the reference transform errors when description is missing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@runkids runkids merged commit 0ae4e11 into runkids:main May 31, 2026
7 of 8 checks passed
@runkids
Copy link
Copy Markdown
Owner

runkids commented May 31, 2026

@PeterTianbuhan Thanks! Merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants